home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Software Contest 3
/
FM Towns Software Contest 3.iso
/
exp
/
astral
/
a1
/
game
/
source
/
space.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-01-07
|
3KB
|
113 lines
// "space.c"
// ワイヤーフレームによる空間の表現
// ゲーム用カスタムバージョン
#define SORT_OFF
// #define HIT_OFF
// #define GAME_CUSTOM
#include <stdio.h>
#include "wire3d.h"
#include "sin8.c"
extern WIRE_SPACE Space[MAX_OBJECT];
extern WIRE_OBJECT Object[];
extern SCREEN_LOCATE Screen[MAX_OBJECT];
extern int N_page,W_page;
int Sort[MAX_OBJECT];
void wirespace(ANGLE *langle,int *loffset,int obj_num,int page)
{
int i;
int point_w[4][3],z_w;
ANGLE d_angle[MAX_OBJECT][3];
int temp2,temp3,obj_num2;
int pass[MAX_OBJECT];
for(i=0;i<obj_num;i++){
if(Space[i].obj_no==-1){
pass[i]=1;
goto EXIT_roll;
}
pass[i]=0;
point_w[0][0]=Space[i].locate[0]-loffset[0];
point_w[0][1]=Space[i].locate[1]-loffset[1];
point_w[0][2]=Space[i].locate[2]-loffset[2];
point_w[1][0]=( point_w[0][0]*cos_data[langle[1]] +
point_w[0][2]*sin_data[langle[1]])>>7;
point_w[1][2]=(-point_w[0][0]*sin_data[langle[1]] +
point_w[0][2]*cos_data[langle[1]])>>7;
point_w[2][1]=( point_w[0][1]*cos_data[langle[0]]-
point_w[1][2]*sin_data[langle[0]])>>7;
Screen[i].locate[2] = ( point_w[0][1]*sin_data[langle[0]]+
point_w[1][2]*cos_data[langle[0]])>>7;
Screen[i].locate[0] = ( point_w[1][0]*cos_data[langle[2]]-
point_w[2][1]*sin_data[langle[2]])>>7;
Screen[i].locate[1] = ( point_w[1][0]*sin_data[langle[2]]+
point_w[2][1]*cos_data[langle[2]])>>7;
d_angle[i][0]=Space[i].angle[0]-langle[0];
d_angle[i][1]=Space[i].angle[1]-langle[1];
d_angle[i][2]=Space[i].angle[2]-langle[2];
EXIT_roll:
Sort[i]=i;
}
#ifndef SORT_OFF
obj_num2=obj_num-1;
for(i=0;;){
if(Screen[Sort[i]].locate[2]<Screen[Sort[i+1]].locate[2] &&
pass[Sort[i]]==0){
temp2=Sort[i];
Sort[i]=Sort[i+1];
Sort[i+1]=temp2;
temp3=1;
}
i++;
if(i==obj_num2){
if(temp3==0)goto EXIT_sort;
i=0;
temp3=0;
}
}
EXIT_sort:
#endif
#ifdef GAME_CUSTOM
wait_VSYNC();
chgpage(N_page);
clear_screen(W_page,6);
star(langle,W_page);
#endif
for(i=0;i<obj_num;i++){
if(Screen[Sort[i]].locate[2]>-(Object[Space[Sort[i]].obj_no].size)
&& Screen[Sort[i]].locate[2]<65536 && pass[Sort[i]]==0)
wire3d(d_angle[Sort[i]],Screen[Sort[i]].locate,
&Object[Space[Sort[i]].obj_no],page);
}
#ifndef HIT_OFF
for(i=0;i<obj_num;i++){
if(pass[i]==1)continue;
z_w=Screen[i].locate[2]+0x100;
if(z_w<=0)continue;
Screen[i].locate[0]=(( Screen[i].locate[0]<<8)/z_w)+128;
Screen[i].locate[1]=((-Screen[i].locate[1]<<8)/z_w)+120;
}
#endif
}